﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;
using System.Windows.Forms;
using DatabaseCore;
using DatabaseCore.Dto;
using Eaktest;
using SystemCore;

namespace EakTest
{
    public partial class ProductSummaryInquiry : BaseForm
    {
        private IProductSummaryDao productSummaryDao = new ProductSummaryDao();
        private IList<ProductSummaryDto> ProductSummarySource { get; set; }

        public ProductSummaryInquiry()
        {
            InitializeComponent();

            GetAllProductSummary();
            BindData();
        }

        #region Private method

        private void GetAllProductSummary()
        {
            ProductSummarySource = productSummaryDao.GetProductSummary();
        }

        private void ClearGridView()
        {
            //gvProductSummary.Rows.Clear();
            gvProductSummary.DataSource = null;
        }

        private void BindData()
        {
            ClearGridView();

            gvProductSummary.DataSource = ProductSummarySource;
        }

        #endregion

        private void btnSearch_Click(object sender, EventArgs e)
        {
            string ProductCode = txtProductCode.Text;
            string OrderNo = txtOrderNo.Text;

            ProductSummarySource = productSummaryDao.GetProductSummary(ProductCode, OrderNo);
            BindData();
        }

    }
}